//
//  PoliteVc.m
//  WY_BookFlowers
//
//  Created by wangyang on 2020/1/13.
//  Copyright © 2020 wangyang. All rights reserved.
//

#import "PoliteVc.h"
#import "CouponsVc.h"
@interface PoliteVc ()

@property (nonatomic,strong) UIScrollView   *WyScrollView;


@end

@implementation PoliteVc

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.navigationItem.title = @"我的优惠卷";
     self.view.backgroundColor = UIColorFromRGB(0xFAFAFA);
    
     [self WyScrollView];
   if (@available(iOS 11.0, *)) {
              
              self.WyScrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
          }
    [self initSetUI];
}

-(void)initSetUI

{
     NSArray *imgArray = @[@"优惠卷1",@"优惠卷2",@"优惠卷3"];
    for (int i = 0; i<imgArray.count; i++) {
        UIButton *btn = [UIButton ButtonWithText:@"" superView:self.WyScrollView TextNormalcolor:[UIColor clearColor] backgroundColor:[UIColor clearColor] fontSize:14 addTarget:self selector:@selector(selector:)];
        [btn setBackgroundImage:[UIImage imageNamed:imgArray[i]] forState:0];
        [btn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.equalTo(CGSizeMake(WySCREENWIDTH-BiLiWidth(30), BiLiWidth(100)));
            make.centerX.mas_offset(BiLiWidth(0));
            make.top.mas_offset(BiLiWidth(20)+BiLiWidth(120)*i);
        }];
        btn.tag = i;
        
    }
    
}


-(void)selector:(UIButton *)button{
    if (button.tag == 0) {
        [self.navigationController pushViewController:[CouponsVc alloc] animated:YES];
    }
    else if (button.tag == 1)
    {
        [self.navigationController pushViewController:[CouponsVc alloc] animated:YES];
    }
    else if (button.tag == 2)
    {
        [[AlertControllerCustom shareInstance] showAlert:@"优惠卷已过期！" viewController:self];
    }
}


- (UIScrollView *)WyScrollView {
    
    if (!_WyScrollView) {
        _WyScrollView = [[UIScrollView alloc] init];
        [self.view addSubview:_WyScrollView];
        _WyScrollView.userInteractionEnabled = YES;
        _WyScrollView.showsVerticalScrollIndicator = NO;
        _WyScrollView.backgroundColor = [UIColor clearColor];
        _WyScrollView.contentSize = CGSizeMake(WySCREENWIDTH, WySCREENHEIGHT*1.5);
        [_WyScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.top.bottom.mas_offset(0);
        }];
       
        
    }
    return _WyScrollView;
}



/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
